package com.upf1sh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.upf1sh.bean.ChickenFarmInfo;
import com.upf1sh.bean.RebootData;
import com.upf1sh.mapper.ChickenFarmInfoMapper;
import com.upf1sh.service.IChickenFarmInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @Description:
 * @Title: ChickenFarmInfoServiceImpl
 * @Package com.upf1sh.service.impl
 * @Author: ZhaoXu
 * @CreateTime: 2025/2/19 20:51
 */
@Service
public class ChickenFarmInfoServiceImpl implements IChickenFarmInfoService
{
    @Autowired
    private ChickenFarmInfoMapper chickenFarmInfoMapper;

    /**
     * 查询养鸡场相关信息
     *
     * @param id 养鸡场相关信息主键
     * @return 养鸡场相关信息
     */
    @Override
    public ChickenFarmInfo selectChickenFarmInfoById(Long id)
    {
        return chickenFarmInfoMapper.selectById(id);
    }

    /**
     * 查询养鸡场相关信息列表
     *
     * @param chickenFarmInfo 养鸡场相关信息
     * @return 养鸡场相关信息
     */
    @Override
    public IPage<ChickenFarmInfo> getPage(ChickenFarmInfo chickenFarmInfo)
    {
        Page<ChickenFarmInfo> page = new Page<>(chickenFarmInfo.getPageSize(), chickenFarmInfo.getPageNum());
        //查询分页结果
        return chickenFarmInfoMapper.selectPage(page,null);
    }

    /**
     * 新增养鸡场相关信息
     *
     * @param chickenFarmInfo 养鸡场相关信息
     * @return 结果
     */
    @Override
    public int insertChickenFarmInfo(ChickenFarmInfo chickenFarmInfo)
    {
        return chickenFarmInfoMapper.insert(chickenFarmInfo);
    }

    /**
     * 修改养鸡场相关信息
     *
     * @param chickenFarmInfo 养鸡场相关信息
     * @return 结果
     */
    @Override
    public int updateChickenFarmInfo(ChickenFarmInfo chickenFarmInfo)
    {
        return chickenFarmInfoMapper.updateById(chickenFarmInfo);
    }

    /**
     * 批量删除养鸡场相关信息
     *
     * @param ids 需要删除的养鸡场相关信息主键
     * @return 结果
     */
    @Override
    public int deleteChickenFarmInfoByIds(Long[] ids)
    {
        return chickenFarmInfoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除养鸡场相关信息信息
     *
     * @param id 养鸡场相关信息主键
     * @return 结果
     */
    @Override
    public int deleteChickenFarmInfoById(Long id)
    {
        return chickenFarmInfoMapper.deleteById(id);
    }
}